<?php

/**
 * This is the model class for table "wp_badan_usaha".
 *
 * The followings are the available columns in table 'wp_badan_usaha':
 * @property string $npwpd_badan
 * @property string $nama_badan
 * @property string $alamat_badan
 * @property string $rt_badan
 * @property string $rw_badan
 * @property string $kelurahan_badan
 * @property string $kecamatan_badan
 * @property string $kabupaten_badan
 * @property string $no_telepon_badan
 * @property string $no_telepon_pemilik
 * @property string $kode_posbu
 * @property string $kode_kb
 * @property string $bidang_usaha
 * @property string $nomor_induk
 * @property string $jabatan
 * @property string $status_aktif
 * @property string $tanggal
 *
 * The followings are the available model relations:
 * @property KelompokBu $kodeKb
 * @property PemilikWp $nomorInduk
 */
class WpBadanUsaha extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'wp_badan_usaha';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('npwpd_badan', 'required'),
			array('npwpd_badan, no_telepon_badan, no_telepon_pemilik, nomor_induk', 'length', 'max'=>20),
			array('nama_badan', 'length', 'max'=>75),
			array('alamat_badan', 'length', 'max'=>125),
			array('rt_badan, rw_badan', 'length', 'max'=>3),
			array('kelurahan_badan, kecamatan_badan, kabupaten_badan, jabatan', 'length', 'max'=>35),
			array('kode_posbu', 'length', 'max'=>10),
			array('kode_kb, status_aktif', 'length', 'max'=>2),
			array('bidang_usaha', 'length', 'max'=>85),
			array('tanggal', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('npwpd_badan, nama_badan, alamat_badan, rt_badan, rw_badan, kelurahan_badan, kecamatan_badan, kabupaten_badan, no_telepon_badan, no_telepon_pemilik, kode_posbu, kode_kb, bidang_usaha, nomor_induk, jabatan, status_aktif, tanggal', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'kodeKb' => array(self::BELONGS_TO, 'KelompokBu', 'kode_kb'),
			'nomorInduk' => array(self::BELONGS_TO, 'PemilikWp', 'nomor_induk'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'npwpd_badan' => 'Npwpd Badan',
			'nama_badan' => 'Nama Badan',
			'alamat_badan' => 'Alamat Badan',
			'rt_badan' => 'Rt Badan',
			'rw_badan' => 'Rw Badan',
			'kelurahan_badan' => 'Kelurahan Badan',
			'kecamatan_badan' => 'Kecamatan Badan',
			'kabupaten_badan' => 'Kabupaten Badan',
			'no_telepon_badan' => 'No Telepon Badan',
			'no_telepon_pemilik' => 'No Telepon Pemilik',
			'kode_posbu' => 'Kode Posbu',
			'kode_kb' => 'Kode Kb',
			'bidang_usaha' => 'Bidang Usaha',
			'nomor_induk' => 'Nomor Induk',
			'jabatan' => 'Jabatan',
			'status_aktif' => 'Status Aktif',
			'tanggal' => 'Tanggal',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('npwpd_badan',$this->npwpd_badan,true);
		$criteria->compare('nama_badan',$this->nama_badan,true);
		$criteria->compare('alamat_badan',$this->alamat_badan,true);
		$criteria->compare('rt_badan',$this->rt_badan,true);
		$criteria->compare('rw_badan',$this->rw_badan,true);
		$criteria->compare('kelurahan_badan',$this->kelurahan_badan,true);
		$criteria->compare('kecamatan_badan',$this->kecamatan_badan,true);
		$criteria->compare('kabupaten_badan',$this->kabupaten_badan,true);
		$criteria->compare('no_telepon_badan',$this->no_telepon_badan,true);
		$criteria->compare('no_telepon_pemilik',$this->no_telepon_pemilik,true);
		$criteria->compare('kode_posbu',$this->kode_posbu,true);
		$criteria->compare('kode_kb',$this->kode_kb,true);
		$criteria->compare('bidang_usaha',$this->bidang_usaha,true);
		$criteria->compare('nomor_induk',$this->nomor_induk,true);
		$criteria->compare('jabatan',$this->jabatan,true);
		$criteria->compare('status_aktif',$this->status_aktif,true);
		$criteria->compare('tanggal',$this->tanggal,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return WpBadanUsaha the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
